package day07;

import jdk.nashorn.api.tree.ForInLoopTree;

import java.util.Random;
import java.util.Spliterator;

public class VerificationCode {
    /*生成？位的验证码，包含大小写字母和随机数*/
    public static void main(String[] args) {
        String code =generateVeriCode(4);
        System.out.print("验证码："+code);

    }


    public static String generateVeriCode(int len){
        String code="";
        char[] chs={'q','w','e','r','t','y','u','i','o','p','a','a','s','d','f','g','h',
                   'j','k', 'l','z','x','c','v','b','n','m','Q','W','E','R','T','Y','U',
                   'I', 'O','P', 'A','S','D','F','G','H','J','K','L','Z','X','C','V','B',
                   'N', 'M','1','2','3','4', '5','6','7','8','9','0'};
        Random random=new Random();
        for (int i = 0; i <len ; i++) {
            int index= random.nextInt(chs.length);//随机生成下标
            code=code+chs[index];
        } /*i=1  index=0   code=q
              2        2       w
               ...
              4       6        y*/

        return code;
    }
}
